home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / (A)TA / (A)TAJ.ADF / Othello / OthHelp.c < prev    next >
C/C++ Source or Header  |  1986-11-06  |  10KB  |  275 lines

  1. /********************** Othello Source File #2 *********************
  2.                         ----------------------
  3.  *******************************************************************
  4.  *                                                                 *
  5.  *      procedure name:          info_display                      *
  6.  *                                                                 *
  7.  *      referenced by:           othello                           *
  8.  *                                                                 *
  9.  *      includes:                othmenu.h                         *
  10.  *                                                                 *
  11.  *******************************************************************/
  12.  
  13. #include <exec/types.h>
  14. #include <lattice/stdio.h>
  15. #include <intuition/intuition.h>
  16.  
  17. #include "othmenu.h"
  18.  
  19. #define LINEHEIGHT 8
  20.  
  21. extern USHORT *ourpointer;
  22.  
  23. extern struct TextAttr smallfont;
  24.  
  25. struct IntuiText string =
  26. {
  27.    1, 0,             /* frontpen, backpen */
  28.    JAM2,             /* drawmode          */
  29.    0,0,              /* leftedge, topedge */
  30.    &smallfont,       /* pointer to font   */
  31.    NULL,             /* pointer to text data */
  32.    NULL              /* next text */
  33. };
  34.  
  35. struct Window *info_window;
  36.  
  37. short    info_xoff, info_yoff;
  38.  
  39. struct NewWindow nwi =
  40.    {
  41.    10,10,
  42.    324,180,
  43.    -1,-1,
  44.    MOUSEBUTTONS,
  45.    NOCAREREFRESH | WINDOWDRAG | SMART_REFRESH | ACTIVATE,
  46.    NULL,
  47.    NULL,
  48.    (UBYTE *)"CSOthello Online Help!",
  49.    NULL,
  50.    NULL,
  51.    300,180,
  52.    300,180,
  53.    WBENCHSCREEN
  54.    };
  55.  
  56. BOOL info_display(menu,item,subitem)
  57. int menu, item, subitem;
  58. {
  59.    char     *text[20];
  60.    USHORT   numpages, page, line;
  61.    UBYTE    *blank = "                                       ";
  62.  
  63.  
  64.    if (!(info_window = (struct Window *)OpenWindow(&nwi) ))
  65.    {
  66.       printf("Can't open info_window!\n");
  67.       return(FALSE);
  68.    }
  69.    info_xoff = info_window->BorderLeft;
  70.    info_yoff = info_window->BorderTop;
  71.    if (ourpointer)
  72.       SetPointer(info_window,ourpointer,POINTERHEIGHT,POINTERWIDTH,POINTERXOFF,POINTERYOFF);
  73.  
  74.    page = numpages = 0;
  75.  
  76.    do
  77.    {
  78.       for (line = 0; line < 20; line++)
  79.          text[line] = NULL;
  80.       numpages = 1;
  81.  
  82.       switch (menu)
  83.       {
  84.          case PROJECT :
  85.             switch (item)
  86.             {
  87.                case NEWGAME :
  88.                   text[00] = "This function starts the game over";
  89.                   text[01] = "with the first turn going to the";
  90.                   text[02] = "appropriate player.";
  91.                   break;
  92.                case BOARDSIZE :
  93.                   text[00] = "These functions set the size of the";
  94.                   text[01] = "board.  The standard size is an eight";
  95.                   text[02] = "by eight board.  Larger boards can";
  96.                   text[03] = "take rather a long time to complete.";
  97.                   text[04] = "Changing the size of the board";
  98.                   text[05] = "restarts the game.";
  99.                   break;
  100.                case OPEN   :
  101.                   text[00] = "This function is used to reload a";
  102.                   text[01] = "saved game.";
  103.                   break;
  104.                case SAVEGAME :
  105.                   text[00] = "This function saves the current status";
  106.                   text[01] = "of a game so that it can be resumed.";
  107.                   text[02] = "To resume a stored game, use OPEN to";
  108.                   text[03] = "reload it.";
  109.                   break;
  110.                case SAVEDEF :
  111.                   text[00] = "This function saves a file that";
  112.                   text[01] = "stores the desired initial setup of";
  113.                   text[02] = "the game.  It stores the board size,";
  114.                   text[03] = "the difficulty levels of each player";
  115.                   text[04] = "and whether or not the game is in";
  116.                   text[05] = "STEPTHROUGH or RACETHROUGH mode.";
  117.                   text[06] = "This file is saved under the name";
  118.                   text[07] = "othello.def and is automatically";
  119.                   text[08] = "loaded whenever the game is run if it";
  120.                   text[09] = "is in the current directory.";
  121.                   break;
  122.                case ABOUT  :
  123.                   text[00] = "      This program was written by:";
  124.  
  125.                   text[02] = "           ** CygnusSoft **";
  126.  
  127.                   text[04] = "      Copyright 1986, CygnusSoft";
  128.                   text[05] = "This program is public domain and";
  129.                   text[06] = "may be freely distributed for no";
  130.                   text[07] = "charge.  The source is also public";
  131.                   text[08] = "domain and any improvements are";
  132.                   text[09] = "encouraged as long as the above notice";
  133.                   text[10] = "is retained.";
  134.  
  135.                   text[12] = "Please address any correspondence to:";
  136.  
  137.                   text[14] = "CygnusSoft";
  138.                   text[15] = "407-1280 Haro St,";
  139.                   text[16] = "Vancouver, BC";
  140.                   text[17] = "Canada";
  141.                   text[18] = "V6E1E8";
  142.                   break;
  143.                case HELP   :
  144.                   switch (subitem)
  145.                      {
  146.                      case FUNCTION :
  147.                         text[00] = "This is the function you're using";
  148.                         text[01] = "right now.  Use it to get help on all";
  149.                         text[02] = "the menu options available.";
  150.                         break;
  151.                      case ALL :
  152.                         text[00] = "Othello, by CygnusSoft,  is a game";
  153.                         text[01] = "of skill where each move can have";
  154.                         text[02] = "effects that last the rest of the";
  155.                         text[03] = "game.  The two players take turns";
  156.                         text[04] = "placing pieces on the board.  You flip";
  157.                         text[05] = "over your opponents pieces by trapping";
  158.                         text[06] = "one or more rows, columns or diagonals";
  159.                         text[07] = "of your opponents pieces between the";
  160.                         text[08] = "piece that you play and pieces of your";
  161.                         text[09] = "color already on the board.  Each time";
  162.                         text[10] = "you make a move you must flip over at";
  163.                         text[11] = "least one of your opponents pieces.";
  164.                         text[12] = "Whoever has the most pieces when the";
  165.                         text[13] = "board is full, or when neither player";
  166.                         text[14] = "can move, is the winner.";
  167.                         break;
  168.                      }
  169.                   break;
  170.                case QUIT   :
  171.                   text[00] = "This function quits the program";
  172.                   text[01] = "completely.  It is the same as";
  173.                   text[02] = "selecting the close window gadget.";
  174.                   break;
  175.             }
  176.             break;
  177.          case PLAYER1   :
  178.          case PLAYER2   :
  179.             text[00] = "These functions set the difficulty";
  180.             text[01] = "level.  On level four the computer may";
  181.             text[02] = "have to think for about half a minute,";
  182.             text[03] = "so be patient.  'Human', of course,";
  183.             text[04] = "means that a human player ( you! ) is";
  184.             text[05] = "controlling that player.  Simply tap";
  185.             text[06] = "with the left mouse button in the";
  186.             text[07] = "square you'd like to make your move";
  187.             text[08] = "in.  If it's a legal move, the computer";
  188.             text[09] = "will flip over all the pieces that";
  189.             text[10] = "should be flipped.  If it is not a";
  190.             text[11] = "legal move, you'll be told.";
  191.  
  192.             text[13] = "If you are not very good at Othello,";
  193.             text[14] = "set your opponents difficulty level";
  194.             text[15] = "to 'Not good', 'Bad', 'Worse' or";
  195.             text[16] = "hopeless.  This will give it a";
  196.             text[17] = "stupidity level of 1-4.";
  197.             break;
  198.          case GURUVSGURU   :
  199.             text[00] = "If the computer is playing against";
  200.             text[01] = "itself these two choices set whether";
  201.             text[02] = "or not the program waits for the user";
  202.             text[03] = "to tap the screen with the left mouse";
  203.             text[04] = "button before going on to the next";
  204.             text[05] = "move.  In STEPTHROUGH mode you must";
  205.             text[06] = "tap the screen after each turn, in";
  206.             text[07] = "RACETHROUGH mode the program never";
  207.             text[08] = "stops.";
  208.             break;
  209.          case OTHER  :
  210.             switch (item)
  211.                {
  212.                case MOVES  :
  213.                   text[00] = "This function displays all the moves";
  214.                   text[01] = "available to the current player.";
  215.                   break;
  216.                case SUGGEST :
  217.                   text[00] = "This function displays the move that";
  218.                   text[01] = "the computer thinks would be best for";
  219.                   text[02] = "the current player to make.  The";
  220.                   text[03] = "computer does it's thinking at the";
  221.                   text[04] = "level three intelligence level.";
  222.                   break;
  223.                }
  224.             break;
  225.       }
  226.       if (text[0] == NULL)
  227.          text[0] = "No information available!";
  228.  
  229.       for (line = 0; line < 20; line++)
  230.          if (text[line])
  231.             printline(text[line], line);
  232.       waitformouseclick(info_window);
  233.  
  234.       page++;
  235.       if (page < numpages)
  236.          for (line = 0; line < 20; line++)      /* clear window */
  237.             printline(blank, line);
  238.  
  239.    } while (page < numpages);
  240.  
  241.    CloseWindow(info_window);
  242. }
  243.  
  244.  
  245.  
  246. waitformouseclick(info_window)
  247. struct Window *info_window;
  248. {
  249.    struct IntuiMessage *message;
  250.    ULONG  class;
  251.    USHORT code;
  252.  
  253.    do
  254.    {
  255.       WaitPort(info_window->UserPort);
  256.       message = (struct IntuiMessage *)GetMsg(info_window->UserPort);
  257.       class = message->Class;
  258.       code = message->Code;
  259.       ReplyMsg(message);
  260.    }  while ((class != MOUSEBUTTONS) || (code != SELECTUP));
  261. }
  262.  
  263.  
  264.  
  265. printline(text, y)
  266. char     *text;
  267. short    y;
  268. {
  269.    string.IText = text;
  270.    PrintIText(info_window->RPort, &string, info_xoff, info_yoff + y *LINEHEIGHT);
  271. }
  272.  
  273.  
  274. /*************** End of file. ******************/
  275.